package efuliBusiness.efuliApi;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import tools.MD5Util;

import java.util.ArrayList;

/**
 * Created by yangxianming on 2018/5/24.
 * 接口数据的方法是提示用户接口数据的创建方式，并返回相关的数据。
 * 并不需要强制使用
 * 参数字段强制存在
 */
public class WelfarepointSetData {

    //创建企业
    public JSONObject efuli_welfarepoint_corp_create(String request_id, String corp_name, String corp_city, String corp_mail,
                                                     String corp_type, String corp_logo, String corp_addr, String corp_mobile,
                                                     String point_name, String rmb_point_ratio){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("corp_name", corp_name);
        jsonObject.put("corp_city", corp_city);
        jsonObject.put("corp_mail", corp_mail);
        jsonObject.put("corp_type", corp_type);
        jsonObject.put("corp_logo", corp_logo);
        jsonObject.put("corp_addr", corp_addr);
        jsonObject.put("corp_mobile", corp_mobile);
        jsonObject.put("point_name", point_name);
        jsonObject.put("rmb_point_ratio", rmb_point_ratio);
        return jsonObject;
    }

    //企业充值
    public JSONObject efuli_welfarepoint_corp_recharge(String request_id, String corp_code, String amount){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("corp_code", corp_code);
        jsonObject.put("amount", amount);
        return jsonObject;
    }

    //创建会员
    public JSONObject efuli_welfarepoint_member_create(String request_id, String corp_code, ArrayList<Member> members){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("corp_code", corp_code);

        JSONArray jsonArray = new JSONArray();
        for (Member member: members){
            jsonArray.add(member.getMember());
        }
        jsonObject.put("staff_arr", jsonArray);

        return jsonObject;
    }

    //会员充值
    public JSONObject efuli_welfarepoint_recharge(String request_id, String corp_code, String recharge_type, ArrayList<Recharge_arr> Recharge_arrs){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("corp_code", corp_code);
        jsonObject.put("recharge_type", recharge_type);

        JSONArray jsonArray = new JSONArray();
        for (Recharge_arr recharge_arr: Recharge_arrs){
            jsonArray.add(recharge_arr.getRecharge_arr());
        }
        jsonObject.put("recharge_arr", jsonArray);
        return jsonObject;
    }

    //efuli.data.query
    public JSONObject efuli_data_query(String request_id, String sql){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("sql", sql);
        jsonObject.put("msign", MD5Util.md5(request_id + "efuli@2099"));
        jsonObject.put("clazz", "com.alipayeco.efuliprod.model.point.po.WfCorporation");
        return jsonObject;
    }
    //efuli.data.update  step 1
    public JSONObject efuli_data_update1(String request_id){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("step", "1");
        return jsonObject;
    }
    //efuli.data.update  step 2
    public JSONObject efuli_data_update2(String request_id, String sql, String token){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("request_id", request_id);
        jsonObject.put("step", "2");
        jsonObject.put("sql", sql);
        jsonObject.put("clazz", "com.alipayeco.efuliprod.model.point.po.WfCorporation");
        jsonObject.put("token", token);
        return jsonObject;
    }
}
